using System;
using System.Data;
using System.Collections.Generic;

namespace shfa.snomtastic.data.business
{
    public partial class FirmwareController
    {
		private FirmwareInfo ObjectFromDataRow(DataRow dr)
        {
            if (dr != null)
            {
				FirmwareInfo obj = new FirmwareInfo();
				obj.FirmwareId = dr.Field<Guid>("FirmwareId"); 
				obj.ModelId = (dr["ModelId"] != DBNull.Value) ? dr.Field<Guid>("ModelId") : Guid.Empty; 
				obj.ConfigurationId = (dr["ConfigurationId"] != DBNull.Value) ? dr.Field<Guid>("ConfigurationId") : Guid.Empty; 
				obj.Version = (dr["Version"] != DBNull.Value) ? dr.Field<String>("Version") : string.Empty; 
				obj.Description = (dr["Description"] != DBNull.Value) ? dr.Field<String>("Description") : string.Empty; 
				obj.BootLoader = (dr["BootLoader"] != DBNull.Value) ? dr.Field<String>("BootLoader") : string.Empty; 
				obj.UpgardeTo = (dr["UpgardeTo"] != DBNull.Value) ? dr.Field<Guid>("UpgardeTo") : Guid.Empty; 
				obj.SendXML = (dr["SendXML"] != DBNull.Value) ? dr.Field<Boolean>("SendXML") : false; 
				obj.FileUrl = (dr["FileUrl"] != DBNull.Value) ? dr.Field<String>("FileUrl") : string.Empty; 
				return obj;
            }
            return null;
        }

        private List<FirmwareInfo> ListFromDataTable(DataTable dt)
        {
            List<FirmwareInfo> lst = new List<FirmwareInfo>();

            foreach (DataRow dr in dt.Rows)
            {
                lst.Add(ObjectFromDataRow(dr));
            }

            return lst;
        }
    }
}
